#include <iostream>
#include <pthread.h>
#include <unistd.h>

using namespace std;

void* thread_run(void* args)
{
  while(true){
    cout << (char*)args << endl;
    sleep(2);
  }
}

int main()
{
  pthread_t tid;
  pthread_create(&tid, nullptr, thread_run, (void*)"thread 1"); //创建线程，获取线程id，传入线程属性，回调函数及其参数
  //主线程继续执行
  while(true)
  {
    cout << "main thread is running..." << endl;
    sleep(1);
  }
  return 0;
}
